<HTML><HEAD><TITLE>add_attribute(?Var, ?Attribute)</TITLE>
</HEAD><BODY>[ <A HREF="index.html">Term Manipulation</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>add_attribute(?Var, ?Attribute)</H1>
Add dynamically an attribute to a variable.


<DL>
<DT><EM>Var</EM></DT>
<DD>Any term.
</DD>
<DT><EM>Attribute</EM></DT>
<DD>Any term.
</DD>
</DL>
<H2>Description</H2>
   The main use of this predicate is for dynamic attributed variables
   creation.  Since the number of declared extensions can vary with time,
   attributes explicitly occurring in the source of extensions might be
   created with less slots than currently necessary.  To make sure that a
   newly created attributed variable will have as many slots as necessary,
   this predicate should be preferred to the equivalent

<P>
<PRE>
    Var = _{Attribute}
</PRE>
   If Var is a free variable, it will be bound to a new attributed variable
   whose attribute corresponding to the caller module name will be
   Attribute.  If Var is already an attributed variable and the
   corresponding attribute is a free variable, it will be bound to
   Attribute.  Otherwise, if the attribute is not a free variable or if Var
   is instantiated, it will be unified with a new attributed variable whose
   corresponding attribute is Attribute and all other attributes are free
   variables.

<P>
   Use add_attribute/3 to add an explicitly named attribute.

<P>

<H3>Modes and Determinism</H3><UL>
<LI>add_attribute(?, ?) is semidet
</UL>
<H3>Modules</H3>
This predicate is sensitive to its module context (tool predicate, see @/2).
<H3>Fail Conditions</H3>
Fails if Var is not a free variable and its unification with the new attributed variable fails
<H3>Exceptions</H3>
<DL>
<DT><EM>(270) undefined variable attribute </EM>
<DD>There is no attribute declared in the caller module.
</DL>
<H2>Examples</H2>
<PRE>
[eclipse 6]: meta_attribute(eclipse, []).

yes.
[eclipse 3]: add_attribute(X, a), printf("%QPMw", X).
X{suspend : _g270 , a}
X = X
yes




</PRE>
<H2>See Also</H2>
<A HREF="../../kernel/termmanip/meta_attribute-2.html">meta_attribute / 2</A>, <A HREF="../../kernel/termmanip/add_attribute-3.html">add_attribute / 3</A>
</BODY></HTML>
